package com.woniu.uums.controller;

import com.woniu.uums.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: finance021
 * @description:
 * @create: 2024-11-06 17:26
 **/
@Controller
public class HomeController {
    @Autowired
    private UserService userService;
    /**
     * 首页
     *
     * @return
     */
    @RequestMapping("/")
    public String home() {
        return "index";
    }

    /**
     * 登录页
     */
    @RequestMapping("/login")
    public String login(String returnUrl, HttpServletRequest request) {
        request.setAttribute("returnUrl", returnUrl);
        return "login";
    }

    /**
     * 登录功能
     */
    @PostMapping("/uums/login")
    public String login(String username,String password,String returnUrl) {
        return userService.login(username,password,returnUrl);
    }
}
